package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.DigitalCollectionProductInfoSubscribeCodeDTO;
import com.sc.nft.entity.dto.DigitalCollectionProductInfoSubscribeCodeRequest;
import com.sc.nft.entity.vo.DigitalCollectionProductInfoSubscribeCodeSummaryVO;
import com.sc.nft.entity.vo.DigitalCollectionProductInfoSubscribeCodeVo;
import com.sc.nft.entity.vo.WinningUsersVO;
import com.sc.nft.service.DigitalCollectionProductInfoSubscribeCodeService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/subscriptionRecords")
@Api(tags = "申购记录")
public class DigitalCollectionProductInfoSubscribeCodeController {

    private final DigitalCollectionProductInfoSubscribeCodeService digitalCollectionProductInfoSubscribeCodeService;

    @PostMapping(value = "/getSubscribeCodePage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取申购记录列表", notes = "获取申购记录列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<DigitalCollectionProductInfoSubscribeCodeVo> getSubscribeCodePage(@Valid @RequestBody DigitalCollectionProductInfoSubscribeCodeDTO request) {
        return PageResult.success(digitalCollectionProductInfoSubscribeCodeService.getSubscribeCodePage(request));
    }

    @PostMapping(value = "/getSubscribeCodeSummary", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取申购列表汇总数据", notes = "获取申购列表汇总数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<DigitalCollectionProductInfoSubscribeCodeSummaryVO> getSubscribeCodeSummary(@Valid @RequestBody IdRequest request) {
        return Result.success(digitalCollectionProductInfoSubscribeCodeService.getSubscribeCodeSummary(request.getId()));
    }

    @PostMapping(value = "/getSubscribeCodeUserPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "中签用户列表分页", notes = "中签用户列表分页", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<WinningUsersVO> getSubscribeCodeUserPage(@Valid @RequestBody DigitalCollectionProductInfoSubscribeCodeRequest request) {
        return PageResult.success(digitalCollectionProductInfoSubscribeCodeService.getSubscribeCodeUserPage(request));
    }


}
